#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn = 1005;
int fa[maxn];
int t,n,h,r;
long long dist;

struct node{
	long long x,y,z;
}a[maxn];

bool cmp(node a,node b){
	return a.z < b.z;
}

int find(int x){
	if(fa[x]==x)return x;
	fa[x]=find(fa[x]);
	return fa[x];
}

void unionn(int a,int b){
	int f1=find(a);
	int f2=find(b);
	if(f1!=f2)fa[f1]=f2;
}

inline bool check(int aa,int bb){
	double dist = sqrt((a[aa].x-a[bb].x)*(a[aa].x-a[bb].x)+(a[aa].y-a[bb].y)*(a[aa].y-a[bb].y)+(a[aa].z-a[bb].z)*(a[aa].z-a[bb].z));
	if(dist<=2*r*1.0)	return true;
	else return false;
}

int main(){
	//freopen("testdata.in","r",stdin);
	cin>>t;
	for(int q=0;q<t;q++){
		cin>>n>>h>>r;
		bool low = false,up = false;
		for(int i=1;i<=n;i++){
			fa[i]=i;
			cin>>a[i].x>>a[i].y>>a[i].z;
			if(low==false && (a[i].z<=r && a[i].z>=(-1*r)))low=true;
			if(up==false && (h-a[i].z<=r && h-a[i].z>=(-1*r)))up=true;
		}
		
		if(low==false || up==false){
			cout<<"No"<<endl;
			continue;
		}
		
		sort(a+1,a+1+n,cmp);
		bool flag=false;
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(check(i,j))	unionn(i,j);
			}
		}
		
		for(int i=1;a[i].z<=r && a[i].z>=(-1*r);i++){
			for(int j=n;h-a[j].z<=r && h-a[j].z>=(-1*r);j--){
				if(find(i)==find(j)){
					flag=true;
					break;
				}
			}
			if(flag)break;
		}
		
		if(flag)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}
